package com.hspedu.tankgame3Exercise;

/**
 * @author DL5O
 * @version 1.0
 * 玩家的坦克
 */
public class MyTank extends Tank {
    Shot shot = null;
    private int shotSpeed = 20;

    public MyTank(int x, int y, int direct, int speed, int type) {
        super(x, y, direct, speed, type);
    }

    /**
     * 当用户按下j键时，就创建shot对象，并启动shot线程
     */
    public void shotEnemy() {
        switch (getDirect()) {
            case 0://上
                shot = new Shot(getX() + 20, getY(), shotSpeed, 0);
                break;
            case 1://右
                shot = new Shot(getX() + 60, getY() + 20, shotSpeed, 1);
                break;
            case 2:
                shot = new Shot(getX() + 20, getY() + 60, shotSpeed, 2);
                break;
            case 3:
                shot = new Shot(getX(), getY() + 20, shotSpeed, 3);
                break;
            default:
                break;
        }
        Thread thread = new Thread(shot);
        thread.start();
    }
}
